/*
 * DataFile.java
 *
 * Created on 2 de octubre de 2007, 15:18
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author alejo
 */
package Utils;

import java.io.FileWriter;
public class DataFile {
    

    
    private FileWriter file=null;
    private String fileName=null;
    private String path=null;
    
    private static final String ending =".txt";
   
    
    
    
    
    
    
    
    
    /** Creates a new instance of ClientFile */
    public DataFile(String fileName, String path) {
        this.fileName=fileName;
        this.path=path;
        this.file=file;
        createFile();
    }
        

    
    
    
    public void writeString(String cadena)
    {
        try
        {
            file.write(cadena);
            file.flush();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            
        }
        
    }
    
    
    
    
    public FileWriter createFile(){
        file=null;
        try{
           
            file=new FileWriter(path + "/"+fileName+ending);
            
            
            //file.write("aloha");             
            //file.write("\n"); 
            
            file.flush();
        }
        catch(Exception e){
            e.printStackTrace();
            return null;        
        }
        
        return file;        
    }
}
